package org.wxd.media.schdcenter.base;

import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.MessageProperties;
import org.wxd.common.utils.JsonUtil;

/**
 * Created by wangxd on 2016/10/11.
 */

public abstract class SchdcenterHandler {

    protected <T> T getMessage(Message message,Class<T> clazz){
        return JsonUtil.parse(new String(message.getBody()),clazz);
    }

    protected <T> T getMessage(Message message,Class<?> collectionClass,Class<?> clazz){
        return JsonUtil.parse(new String(message.getBody()),collectionClass,clazz);
    }

    protected Message buildMessage(Object arg){
        return new Message(JsonUtil.stringify(arg).getBytes(),new MessageProperties());
    }
}
